package es.kivitel.android.sms.utils;

import java.util.Calendar;

import android.widget.DatePicker;
import android.widget.TimePicker;

public class DateSerializer {
	
	private Calendar mDate;

	public DateSerializer( long timeInMillis ){
		mDate = Calendar.getInstance();
		mDate.setTimeInMillis( timeInMillis );
	}	
	
	public DateSerializer( DatePicker dp, TimePicker tp ){
		mDate = Calendar.getInstance();
		mDate.set( Calendar.YEAR, dp.getYear() );
		mDate.set( Calendar.MONTH, dp.getMonth() );
		mDate.set( Calendar.DAY_OF_MONTH, dp.getDayOfMonth() );
		mDate.set( Calendar.HOUR_OF_DAY, tp.getCurrentHour() );
		mDate.set( Calendar.MINUTE, tp.getCurrentMinute() );
	}

	public DateSerializer( int year, int month, int day, int hour, int minute ){
		mDate = Calendar.getInstance();
		mDate.set( Calendar.YEAR, year );
		mDate.set( Calendar.MONTH, month );
		mDate.set( Calendar.DAY_OF_MONTH, day );
		mDate.set( Calendar.HOUR_OF_DAY, hour );
		mDate.set( Calendar.MINUTE, minute );		
	}

	public long getSerializedDate(){
		return mDate.getTimeInMillis();
	}
	
	public int getYear(){
		return mDate.get( Calendar.YEAR );
	}

	public void setYear( int year ){
		mDate.set( Calendar.YEAR, year );
	}
	
	public int getMonth(){
		return mDate.get( Calendar.YEAR );
	}

	public void setMonth( int month ){
		mDate.set( Calendar.YEAR, month );
	}	
	
	public int getDay(){
		return mDate.get( Calendar.DAY_OF_MONTH );
	}

	public void setDay( int day ){
		mDate.set( Calendar.DAY_OF_MONTH, day );
	}		
}
